#ifndef __SUBSYSTEM_PATHFINDING_H__
#define __SUBSYSTEM_PATHFINDING_H__

#include "AStar/AStarVector3.h"
#include "Subsystems/Subsystem.hpp"

namespace PocketSurvival
{
    class SubsystemPathfinding : public Subsystem
    {
    protected:
        SubsystemTerrain *m_terrain;
        std::shared_ptr<AStarVector3> m_astar;

    public:
        void pathSearch(const Vector3 &start, const Vector3 &end, float minDistance, const Vector3 &boxSize, int32_t maxPositionsToCheck, PathfindingResult *result);
        void smoothPath(std::vector<Vector3> &path, const Vector3 &boxSize);
        bool isPassable(const Vector3 &p1, const Vector3 &p2, const Vector3 &boxSize);
        static bool SmoothingRaycastFunction_Obstacle(int32_t value, float distance);
        static bool SmoothingRaycastFunction_Support(int32_t value, float distance);

        virtual const std::string &getName() const override;
        virtual void load(const nlohmann::json &json) override;
    };

} // namespace PocketSurvival

#endif
